# Customise this file, documentation can be found here:
# https://github.com/fastlane/fastlane/tree/master/fastlane/docs
# All available actions: https://docs.fastlane.tools/actions
# can also be listed using the `fastlane actions` command

# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`

# If you want to automatically update fastlane if a new version is available:
# update_fastlane

# This is the minimum version number required.
# Update this, if you use features of a newer version
fastlane_version "2.29.0"

default_platform :ios

platform :ios do
  before_all do
    # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."
    
    
  end


desc "使用libmanager lane,用来管理和更新远程私有库"
lane :libmanager do |options|

# 接收自定义参数options
tag_name = options[:tag] # 标签名
target_name = options[:target] # podspec名称
repo_name = options[:repo] # 远程私有库名称

# 1. pod install
cocoapods(
 clean: true,
 podfile: "./Example/Podfile"
)

# 2. git add .
git_add(path: ".")

# 3. git commit -m "xxx"
git_commit(path: ".",message: "静态库版本维护更新")

# 4. git push xxxx master
push_to_git_remote(
 remote: "origin",         # optional, default: "origin"
# local_branch: "develop",  # optional, aliased by "branch", default: "master"
# remote_branch: "develop", # optional, default is set to local_branch
 force: true,    # optional, default: false
 tags: false     # optional, default: true
)

# 5. git tag "标签名"
add_git_tag(tag: tag_name)

# 6. git push --tags
push_git_tags

# 7. pod xxx.spec lint
pod_lib_lint(allow_warnings: true)

# 8. pod repo push xxxxx xxx.podspec
pod_push(path: "#{target_name}.podspec", repo: repo_name, allow_warnings: true)

end

desc "gym 打包IPA"
lane :gymarchipa do |options|

scheme_name = options[:scheme] # 需要打包的scheme名

gym(
    workspace: "#{scheme_name}.xcworkspace",
    scheme: "#{scheme_name}-Example",
    export_method: "development",
    output_directory: "./build"
)

end

  desc "Runs all the tests"
  lane :test do
    scan
  end

  desc "Submit a new Beta Build to Apple TestFlight"
  desc "This will also make sure the profile is up to date"
  lane :beta do
    # match(type: "appstore") # more information: https://codesigning.guide
    gym # Build your app - more options available
    pilot

    # sh "your_script.sh"
    # You can also use other beta testing services here (run `fastlane actions`)
  end

  desc "Deploy a new version to the App Store"
  lane :release do
    # match(type: "appstore")
    # snapshot
    gym # Build your app - more options available
    deliver(force: true)
    # frameit
  end

  # You can define as many lanes as you want

  after_all do |lane|
    # This block is called, only if the executed lane was successful

    # slack(
    #   message: "Successfully deployed new App Update."
    # )
  end

  error do |lane, exception|
    # slack(
    #   message: exception.message,
    #   success: false
    # )
  end
end


# More information about multiple platforms in fastlane: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
# All available actions: https://docs.fastlane.tools/actions

# fastlane reports which actions are used
# No personal data is recorded. Learn more at https://github.com/fastlane/enhancer
